package com.example.lawyer.community;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lawyer.R;
import com.example.lawyer.databind.assembly.SlidePageViewData;
import com.example.lawyer.databind.assembly.TypeGridData;
import com.example.lawyer.databind.assembly.TypeNewListData;
import com.example.lawyer.databind.assembly.TypeSearchTopData;
import com.example.lawyer.databind.fargment.HomeAData;
import com.example.lawyer.databind.itemview.LawterListItemData;
import com.example.lawyer.databinding.FragmentPageHomeABinding;
import com.example.lawyer.interfacecallback.PageHomeACallback;
import com.example.lawyer.interfaceservice.PageHomeAService;
import com.example.lawyer.interfaceservice.PageHomeCService;


public class PageHomeA extends Fragment implements PageHomeACallback {



    private LayoutInflater layoutInflater;
    private ViewGroup viewGroup;
    private FragmentPageHomeABinding viewDataBinding;
    private HomeAData homeAData;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        layoutInflater = inflater;
        viewGroup = container;
        viewDataBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_page_home_a, container, false);
        homeAData = new HomeAData();
        System.out.println("起步");
        homeAData.HomeASearchTop.set(new TypeSearchTopData());
        viewDataBinding.setHomeadata(homeAData);

        new PageHomeAService().InitTypeData(this);

        new PageHomeAService().InitNewListData(this);
        new PageHomeAService().InitSlideData(this);
        return viewDataBinding.getRoot();
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        System.out.println("开始");




    }


    /***
     * 分类菜单初始化
     * @param gridData
     */
    @Override
    public void InitTypeDataList(TypeGridData gridData) {
        System.out.println("----------------------------");

        System.out.println("----------------------------");
        if(layoutInflater == null)
        {
            System.out.println("kong");

        }
        homeAData.hometypedata.set(gridData);

    }

    /***
     * 推荐律师
     */
    @Override
    public void InitNewDataList(TypeNewListData newList) {
        if(newList==null)
        {
            System.out.println("空的");
            return;
        }
        homeAData.HomeALawterListItemData.set(newList);
    }

    @Override
    public void InitSlideDataList(SlidePageViewData slidePageViewData) {
        if(slidePageViewData==null)
        {
            return;
        }
        homeAData.slidePageViewData.set(slidePageViewData);
    }

    //


}
